#include "page.h"

Page::Page(QWidget *parent) : QWidget(parent) {
	ui.setupUi(this);
	ui.pageNoLabel->setAutoFillBackground(false);
}

void Page::setPixmap(QPixmap pixmap) {
	ui.pageImgLabel->setPixmap(pixmap);
}

void Page::setPageSize(const QSize &size) {
	ui.pageImgLabel->setFixedSize(size);
	ui.pageNoLabel->setFixedWidth(size.width());
}

void Page::setPageNo(int pageNo) {
	pageNumber=pageNo;
	ui.pageNoLabel->setText(tr("%1").arg(pageNo+1));
}


void Page::mousePressEvent(QMouseEvent *) {
	emit pageSelected(pageNumber);
}

void Page::showPage(int page) {
	if (page == pageNumber) {
		QFont f("Sans", 10, QFont::Bold);
		ui.pageNoLabel->setFont(f);
		ui.pageNoLabel->setAutoFillBackground(true);
	} else {
		QFont f("Sans", 9, QFont::Normal);
		ui.pageNoLabel->setFont(f);
		ui.pageNoLabel->setAutoFillBackground(false);
	}
	emit pageSelected();
}

Page::~Page() {

}
